/**
 * 
 */
package edu.arizona.bio5.onto.decomposition;

import java.util.Set;

import org.semanticweb.owlapi.model.OWLEntity;

/**
 * @author Pavel Klinov
 *
 */
public class MSSStatsEvaluator {

	public static MSSStats evalMSSLabels(AtomicDecomposition ad) {
		
		int totalMSS = 0;
		int largestMSS = 0;
		int incomplete = 0;
		int totalMSSUnion = 0;
		
		for (Atom atom : ad.getAtoms()) {
			
			MSSLabel label = (MSSLabel) atom.getLabel(MSSLabel.TYPE);
			int mssSize = label.getSeedSignatures().size();
			
			incomplete += label.isComplete() ? 0 : 1;
			totalMSS += mssSize;
			largestMSS = Math.max(largestMSS, mssSize);
			
			for (Set<OWLEntity> mss : label.getSeedSignatures()) {
				
				totalMSSUnion += mss.size();
			}
		}
		
		double avgMSS = 1d*totalMSS / ad.getAtoms().size();
		double avgMSSUnion = 1d*totalMSSUnion / ad.getAtoms().size();
		
		return new MSSStats(largestMSS, avgMSS, incomplete, avgMSSUnion);
	}
}

class MSSStats {

	double mAvgMSSSize = 0d;
	int mLargestMSS = 0;
	int mDirtyAtomNumber = 0;
	double mAvgMSSUnionSize = 0;
	
	MSSStats(int largestMSS, double avgMSS, int dirtyAtomNumber, double avgMSSUnionSize) {
		mAvgMSSSize = avgMSS;
		mLargestMSS = largestMSS;
		mDirtyAtomNumber = dirtyAtomNumber;
		mAvgMSSUnionSize = avgMSSUnionSize;
	}
	
	public String toString() {
		
		return mLargestMSS + "," + mAvgMSSSize + "," + mDirtyAtomNumber + "," + mAvgMSSUnionSize;
	}
}